using System;
namespace APP.HELPER.Utils.BarcodeLib
{
	internal class ISBN : BarcodeCommon, IBarcode
	{
		public string Encoded_Value
		{
			get
			{
				return this.Encode_ISBN_Bookland();
			}
		}
		public ISBN(string input)
		{
			this.Raw_Data = input;
		}
		private string Encode_ISBN_Bookland()
		{
			if (!BarcodeEdit.CheckNumericOnly(this.Raw_Data))
			{
				throw new Exception("EBOOKLANDISBN-1: Numeric Data Only");
			}
			string a = "UNKNOWN";
			if (this.Raw_Data.Length == 10 || this.Raw_Data.Length == 9)
			{
				if (this.Raw_Data.Length == 10)
				{
					this.Raw_Data = this.Raw_Data.Remove(9, 1);
				}
				this.Raw_Data = "978" + this.Raw_Data;
				a = "ISBN";
			}
			else
			{
				if (this.Raw_Data.Length == 12 && this.Raw_Data.StartsWith("978"))
				{
					a = "BOOKLAND-NOCHECKDIGIT";
				}
				else
				{
					if (this.Raw_Data.Length == 13 && this.Raw_Data.StartsWith("978"))
					{
						a = "BOOKLAND-CHECKDIGIT";
						this.Raw_Data = this.Raw_Data.Remove(12, 1);
					}
				}
			}
			if (a == "UNKNOWN")
			{
				throw new Exception("EBOOKLANDISBN-2: Invalid input.  Must start with 978 and be length must be 9, 10, 12, 13 characters.");
			}
			EAN13 eAN = new EAN13(this.Raw_Data);
			return eAN.Encoded_Value;
		}
	}
}
